import FormBuilder from '@/components/FormBuilder.vue'

export function useForm(props: any) {
  const formref = ref()

  const Component = (_: any, { slots }: any) => {
    return h(FormBuilder, { ...reactive(props), ref: formref }, slots)
  }

  return {
    FormBuilder: Component,
    validate: () => {
      return formref.value?.validate()
    }
  }
}
